<?php


namespace App\DTO;


use App\Models\Board;

class FatBoard implements BaseDTO
{

    /**
     * @var Board
     */
    protected $board;
    protected $inflated;

    /**
     * FatList constructor.
     * @param Board $list
     */
    public function __construct(Board $board)
    {
        $this->board = $board;
        $this->inflated = self::inflateBoard();
    }

    private function inflateBoard()
    {
        $data  = $this->board;
        $data['tasks'] = $data->tasks;
        $data['meta'] = self::getMeta($this->board);
        return $data;
    }

    public function getData()
    {
        return  $this->inflated;
    }

    public static function getInflatedBoard(Board $list)
    {
        return (new FatBoard($list))->getData();
    }

    private static function getMeta(Board $list)
    {
        return [
            'total'=> $list->tasks->count(),
        ];
    }
}